//1 导入express
const express = require('express');

//2 创建应用对象
const app = express();

//设置中间件
app.use((req, res, next)=>{
	console.log('有人请求服务器1了')
	console.log('请求的资源是：', req.url)
	console.log('请求来自于：', req.get('Host'))
	next()
})

//3 创建路由
app.get('/students', (req, res) => {
	res.json([
				{
					id: "001",
					name: "tom",
					age: 18
				},
				{
					id: "002",
					name: "jerry",
					age: 38
				},
				{
					id: "003",
					name: "tony",
					age: 14
				}
	])
})


//4 监听端口
app.listen(5000, () => {
	console.log('服务器1启动成功了，请求学生信息地址为：http://localhost:5000/students')
})